package com.lt.suangua.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.lt.suangua.http.glide.GlideApp;
import com.lt.suangua.http.glide.GlideRoundImage;

public class GlideUtils {
    public static void loadImage(Context context, String url, ImageView imageView){
        GlideApp.with(context)
                .load(url).timeout(30000)
                .into(imageView);
    }
    public static void loadCornerImage(Context context, String url, ImageView imageView,int radius){
        GlideApp.with(context)
                .load(url).timeout(30000)
                .transform(new GlideRoundImage(context, radius))
                .into(imageView);
    }
    public static void loadLongImage(Context context, String url, ImageView imageView){
        RequestOptions requestOptions = new RequestOptions()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
                .priority(Priority.HIGH)
                .format(DecodeFormat.PREFER_RGB_565);

        Glide.with(context)
                .setDefaultRequestOptions(requestOptions)
                .load(url).timeout(30000)
                .into(imageView);
    }
}
